Skip to content

Fix default -m delimiter for note ACL#2410

Open
ankor2023 wants to merge 3 commits intosquid-cache:masterfrom
ankor2023:bugfix-default-comma-delimeter-in-note-acl
Open

Fix default -m delimiter for note ACL#2410
ankor2023 wants to merge 3 commits intosquid-cache:masterfrom
ankor2023:bugfix-default-comma-delimeter-in-note-acl

Conversation

@ankor2023
Copy link
Copy Markdown
Contributor

@ankor2023 ankor2023 commented Apr 22, 2026

This PR fixes a bug where acl note would split values by a comma
even if the -m option was not provided.

Current behavior:
If -m is omitted, AnnotationCheck defaults to a comma (,),
causing tokens to be split unexpectedly.

New behavior:
When -m is not used, no splitting occurs (the entire value is
treated as a single token).

- Renamed internal storage to private 'explicitOrDefaultValue'
- Added public accessors to maintain controlled access.
- Updated call sites to use the new interface.
@squid-anubis squid-anubis added the M-failed-description https://github.com/measurement-factory/anubis#pull-request-labels label Apr 22, 2026
@squid-anubis

This comment was marked as resolved.

@ankor2023 ankor2023 changed the title Fix: Disable unexpected default 'note' ACL splitting without -m option Fix: Avoid unexpected default note ACL split without -m option Apr 22, 2026
@squid-anubis

This comment was marked as resolved.

@squid-anubis

This comment was marked as resolved.

@squid-anubis squid-anubis removed the M-failed-description https://github.com/measurement-factory/anubis#pull-request-labels label Apr 22, 2026
@yadij yadij changed the title Fix: Avoid unexpected default note ACL split without -m option Fix default -m delimiter for note ACL Apr 23, 2026
@yadij
Copy link
Copy Markdown
Contributor

yadij commented Apr 23, 2026

Shortened the title and description to fit within Anubis enforced bounds. Dropped the text listing what the patch contains (redundant), and the reference to original discussion (URL too long for commit message).
Original thread reference is https://ml-archives.squid-cache.org/squid-dev/2026-April/010017.html

Copy link
Copy Markdown
Contributor

@yadij yadij left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some documentation polish for what is there now.

Comment thread src/acl/Options.h Outdated
Comment thread src/acl/Options.h Outdated
void reset() { *this = OptionValue<Value>(); }

Value value; ///< final value storage, possibly after conversions
const Value *value() const { return enabled() ? &explicitOrDefaultValue : nullptr; }; ///< accessor
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const Value *value() const { return enabled() ? &explicitOrDefaultValue : nullptr; }; ///< accessor
/// \retval nullptr Do not use any value for this option.
const Value *value() const { return enabled() ? &explicitOrDefaultValue : nullptr; };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am against the suggestion in this change request because it contains arguably misleading caller instructions (where no instructions are necessary at all) and because the suggested wording implies that a caller has access to multiple option values. I do agree that "accessor" is also problematic and posted a change request with a specific replacement suggestion.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no change from the implications created by the member naming ( "AorB" ) except to clarify that hidden nullptr semantic meaning. I am open to alternatives that clarify the three semantic meanings better.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yadij

There is no change from the implications created by the member naming ( "AorB" ) except to clarify that hidden nullptr semantic meaning. I am open to alternatives that clarify the three semantic meanings better.

Alex suggested the following comment for this method:

/// option value (if the option was enabled) or nil (otherwise)
const Value *value() const { return enabled() ?  &explicitOrDefaultValue : nullptr; }

and for the variable description:

/// When 'valued' is true, this is an explicitly set value.
/// Otherwise, this is the default value.
Value explicitOrDefaultValue;

In my opinion, this covers the three possible semantic meanings quite well.

@yadij yadij added S-waiting-for-more-reviewers needs a reviewer and/or a second opinion backport-to-v7 maintainer has approved these changes for v7 backporting S-waiting-for-author author action is expected (and usually required) labels Apr 23, 2026
Copy link
Copy Markdown
Contributor

@rousskov rousskov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR needs more work. I need more time to flag and/or fix other issues, but I am posting this partial review to facilitate progress and in hope to reduce churn related to already posted change requests.

Comment thread src/acl/Options.h Outdated
Comment thread src/acl/Options.h Outdated
void reset() { *this = OptionValue<Value>(); }

Value value; ///< final value storage, possibly after conversions
const Value *value() const { return enabled() ? &explicitOrDefaultValue : nullptr; }; ///< accessor
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am against the suggestion in this change request because it contains arguably misleading caller instructions (where no instructions are necessary at all) and because the suggested wording implies that a caller has access to multiple option values. I do agree that "accessor" is also problematic and posted a change request with a specific replacement suggestion.

Comment thread src/acl/Options.h Outdated
{
recipient_->value.printChars(os); // TODO: Quote if needed.
if( recipient_->value() ) recipient_->value()->printChars(os); // TODO: Quote if needed.
else os << "[Not set]";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are adding this if statement "just in case", please do not add it. It is the caller's responsibility to check that the value exists as it is not possible to print a non-existing value correctly. This method can (and probably should) assert (using Assure()) that the value exists.

Otherwise, please discuss what caller(s) prompted you to add this if statement.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rousskov

If you are adding this if statement "just in case", please do not add it. It is the caller's responsibility to check that the value exists as it is not possible to print a non-existing value correctly.

I assumed this method could be used for debugging purposes. In this case, as I understand it, the calling procedure might not know whether the internal variable has been set.

This method can (and probably should) assert (using Assure()) that the value exists.

Refactor it to the following, then?

template <>
inline void
TypedOption<CharacterSetOptionValue>::printValue(std::ostream &os) const
{
    Assure(recipient_->value());
    recipient_->value()->printChars(os); // TODO: Quote if needed.
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assumed this method could be used for debugging purposes.

I do not think that is a valid assumption in this case. Debugging code should use higher-level methods that handle non-existent values correctly.

Refactor it to the following, then?

If you really insist. FWIW, my recommendation for this method in this PR is to just add () to get this code to compile. This PR is not about improving other aspects of this method, and the proposed assertion is not related to the primary PR changes.

@rousskov rousskov added S-waiting-for-reviewer ready for review: Set this when requesting a (re)review using GitHub PR Reviewers box and removed S-waiting-for-more-reviewers needs a reviewer and/or a second opinion labels Apr 23, 2026
@rousskov rousskov requested a review from yadij April 23, 2026 13:28
ankor2023 and others added 2 commits April 28, 2026 07:53
Co-authored-by: Alex Rousskov <rousskov@measurement-factory.com>
Co-authored-by: Alex Rousskov <rousskov@measurement-factory.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-to-v7 maintainer has approved these changes for v7 backporting S-waiting-for-author author action is expected (and usually required) S-waiting-for-reviewer ready for review: Set this when requesting a (re)review using GitHub PR Reviewers box

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants